﻿// ----------------------------------------------------------------
// Description : 实体类,该文件由MyGeneration生成
// Author      : 
// Create date : 2009-12-22
// ----------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;

namespace ITOMMS.Entity
{
	/// <summary>
	///	Vw工作日志视图 Entity
	///	Vw工作日志视图 Entity
	/// </summary>
	[Serializable]
	public class Vw工作日志视图Entity : BaseEntity<Vw工作日志视图Entity,int>
	{
		
		#region 私有成员			
		
		private int _ID; 
		private int? _姓名;
        private string _RealName;
        private int? _RoleGroup; 
		private string _DepartmentName; 
		private int? _部门; 
		private string _职位; 
		private DateTime? _日期; 
		private string _客户名称; 
		private string _重要级别; 
		private string _工作性质; 
		private DateTime? _接报时间; 
		private DateTime? _到场时间; 
		private string _消耗时间; 
		private string _工作内容; 
		private DateTime? _CreateDate; 
		private int? _CreateBy; 
		private DateTime? _ModifyDate; 
		private int? _ModifyBy; 
		private int _SEQNO;
		#endregion


		
		#region 默认( 空 ) 构造函数
		/// <summary>
		/// 默认构造函数
		/// </summary>
		public Vw工作日志视图Entity()
		{
			_ID = 0; 
			_姓名 =  null;
            _RealName = String.Empty;
            _RoleGroup = null;
			_DepartmentName = String.Empty; 
			_部门 =  null; 
			_职位 = String.Empty; 
			_日期 =  null; 
			_客户名称 = String.Empty; 
			_重要级别 = String.Empty; 
			_工作性质 = String.Empty; 
			_接报时间 =  null; 
			_到场时间 =  null; 
			_消耗时间 = String.Empty; 
			_工作内容 = String.Empty; 
			_CreateDate =  null; 
			_CreateBy =  null; 
			_ModifyDate =  null; 
			_ModifyBy =  null; 
			_SEQNO = 0;
		}
		#endregion
		
		#region 属性值校验
		
		/// <summary>
		/// 属性值校验
		/// </summary>
		public bool CheckValues()
		{
			bool bResult = true;
			string strError = "";
		
			if ( _ID ==  0)
			{
				bResult = false;
				strError += "\r\n 非空值不能为: "+_ID;
			}
			
			if( !bResult )
					throw new ArgumentOutOfRangeException(strError);
			return bResult;
			
		}
		
		#endregion
		
		
		
	
		#region Required Fields Only Constructor
		
		/// <summary>
		/// required (not null) fields only constructor
		/// </summary>
		public Vw工作日志视图Entity(
		int para_ID		)
		: this()
		{
					_ID = para_ID;
			_姓名 = null;
            _RealName = String.Empty;
            _RoleGroup = null;
			_DepartmentName = String.Empty;
			_部门 = null;
			_职位 = String.Empty;
			_日期 = null;
			_客户名称 = String.Empty;
			_重要级别 = String.Empty;
			_工作性质 = String.Empty;
			_接报时间 = null;
			_到场时间 = null;
			_消耗时间 = String.Empty;
			_工作内容 = String.Empty;
			_CreateDate = null;
			_CreateBy = null;
			_ModifyDate = null;
			_ModifyBy = null;
		}
		#endregion 

		
		#region 公有属性
			
			/// <summary>
			/// 行号，顺序号。系统默认的属性,对这个属性不要作操作.属性值在架构中已经处理
			/// </summary>
			public virtual int SEQNO
			{
				get { return _SEQNO; }
				set { _SEQNO = value; }
			}
		
			
		/// <summary>
		/// ID
		/// </summary>		
		public virtual int ID
		{
			get { return _ID; }
			set { _ID = value; }
		}
			
		/// <summary>
		/// 姓名
		/// </summary>		
		public virtual int? 姓名
		{
			get { return _姓名; }
			set { _姓名 = value; }
		}
			
		/// <summary>
		/// RealName
		/// </summary>		
		public virtual string RealName
		{
			get { return _RealName; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 30)
						throw new ArgumentOutOfRangeException("Invalid value for RealName", value, value.ToString());
				
				_RealName = value;
			}
		}

        /// <summary>
		/// 角色
		/// </summary>		
        public virtual int? RoleGroup
		{
            get { return _RoleGroup; }
            set { _RoleGroup = value; }
		}

        
			
		/// <summary>
		/// DepartmentName
		/// </summary>		
		public virtual string DepartmentName
		{
			get { return _DepartmentName; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 30)
						throw new ArgumentOutOfRangeException("Invalid value for DepartmentName", value, value.ToString());
				
				_DepartmentName = value;
			}
		}
			
		/// <summary>
		/// 部门
		/// </summary>		
		public virtual int? 部门
		{
			get { return _部门; }
			set { _部门 = value; }
		}
			
		/// <summary>
		/// 职位
		/// </summary>		
		public virtual string 职位
		{
			get { return _职位; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for 职位", value, value.ToString());
				
				_职位 = value;
			}
		}
			
		/// <summary>
		/// 日期
		/// </summary>		
		public virtual DateTime? 日期
		{
			get { return _日期; }
			set { _日期 = value; }
		}
			
		/// <summary>
		/// 客户名称
		/// </summary>		
		public virtual string 客户名称
		{
			get { return _客户名称; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for 客户名称", value, value.ToString());
				
				_客户名称 = value;
			}
		}
			
		/// <summary>
		/// 重要级别
		/// </summary>		
		public virtual string 重要级别
		{
			get { return _重要级别; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 10)
						throw new ArgumentOutOfRangeException("Invalid value for 重要级别", value, value.ToString());
				
				_重要级别 = value;
			}
		}
			
		/// <summary>
		/// 工作性质
		/// </summary>		
		public virtual string 工作性质
		{
			get { return _工作性质; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for 工作性质", value, value.ToString());
				
				_工作性质 = value;
			}
		}
			
		/// <summary>
		/// 接报时间
		/// </summary>		
		public virtual DateTime? 接报时间
		{
			get { return _接报时间; }
			set { _接报时间 = value; }
		}
			
		/// <summary>
		/// 到场时间
		/// </summary>		
		public virtual DateTime? 到场时间
		{
			get { return _到场时间; }
			set { _到场时间 = value; }
		}
			
		/// <summary>
		/// 消耗时间
		/// </summary>		
		public virtual string 消耗时间
		{
			get { return _消耗时间; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 50)
						throw new ArgumentOutOfRangeException("Invalid value for 消耗时间", value, value.ToString());
				
				_消耗时间 = value;
			}
		}
			
		/// <summary>
		/// 工作内容
		/// </summary>		
		public virtual string 工作内容
		{
			get { return _工作内容; }
			set	
			{
				
				if ( value != null)
					if( value.Length > 1000)
						throw new ArgumentOutOfRangeException("Invalid value for 工作内容", value, value.ToString());
				
				_工作内容 = value;
			}
		}
			
		/// <summary>
		/// CreateDate
		/// </summary>		
		public virtual DateTime? CreateDate
		{
			get { return _CreateDate; }
			set { _CreateDate = value; }
		}
			
		/// <summary>
		/// CreateBy
		/// </summary>		
		public virtual int? CreateBy
		{
			get { return _CreateBy; }
			set { _CreateBy = value; }
		}
			
		/// <summary>
		/// ModifyDate
		/// </summary>		
		public virtual DateTime? ModifyDate
		{
			get { return _ModifyDate; }
			set { _ModifyDate = value; }
		}
			
		/// <summary>
		/// ModifyBy
		/// </summary>		
		public virtual int? ModifyBy
		{
			get { return _ModifyBy; }
			set { _ModifyBy = value; }
		}
			


		#endregion 	
		
		
        #region DAO操作
		
		
		/// <summary>
        /// 获取所有实体的列表
        /// </summary>
        /// <returns></returns>
        public override List<Vw工作日志视图Entity> GetAll()
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select [ID],[姓名],[RealName],[RoleGroup],[DepartmentName],[部门],[职位],[日期],[客户名称],[重要级别],[工作性质],[接报时间],[到场时间],[消耗时间],[工作内容],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy] from [Vw_工作日志视图] ");
	
            List<Vw工作日志视图Entity> list = new List<Vw工作日志视图Entity>();
            Database db = GetDatabase();
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            {
				int seq = 0;
                while (dataReader.Read())
                {	seq++;
                    list.Add(ReaderBind(dataReader,seq));
                }
            }
            return list;
        }
		
		/// <summary>
        /// 获取所有实体的列表总行数
        /// </summary>
        /// <returns></returns>
        public override int GetTotalRecords()
        {
            StringBuilder strSql = new StringBuilder();
			strSql.Append("  select count([ID])  from [Vw_工作日志视图] ");
	
            Database db = GetDatabase();
            return (int)db.ExecuteScalar(CommandType.Text, strSql.ToString());
        }
		
		/// <summary>
        /// 获取所有实体的列表总行数
        /// </summary>
        /// <returns></returns>
        public override int GetTotalRecords(string sqlCondition)
        {
            StringBuilder strSql = new StringBuilder();
			strSql.Append("  select count([ID])  from [Vw_工作日志视图]  ");
	
			 if (sqlCondition.Trim() != "")
            {
                strSql.Append(" where " + sqlCondition);
            }
            Database db = GetDatabase();
            return (int)db.ExecuteScalar(CommandType.Text, strSql.ToString());
        }	
		
		
		/// <summary>
        /// 按条件查询,得到一页的对应的结果列表
        /// </summary>
        /// <param name="strWhere">条件</param>
		/// <param name="PageSize">每页大小</param>
		/// <param name="CurrentPageIndex">当前页码</param>
        /// <returns></returns>
		 public override List<Vw工作日志视图Entity> GetAllByQuery(string strWhere, int PageSize, int CurrentPageIndex)
        {
            StringBuilder strSql = new StringBuilder();
            if (strWhere.Contains("order".ToLower()))
            {
                throw new Exception("分页查询的sql条件中不能包括排序子句，请调用重载方法实现有条件的排序筛选");
            }

            strSql.Append("select top ").Append(PageSize).Append("  [ID],[姓名],[RealName],[RoleGroup],[DepartmentName],[部门],[职位],[日期],[客户名称],[重要级别],[工作性质],[接报时间],[到场时间],[消耗时间],[工作内容],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy] from [Vw_工作日志视图] where ");

			 if (strWhere.Trim() != "")
            {
                strSql.Append("  " + strWhere + " and ");
            }
			  strSql.Append(" ID not in ( ");
			 strSql.Append(" select top ").Append(PageSize*(CurrentPageIndex-1)).Append("  [ID] from [Vw_工作日志视图] ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere );
            }
			strSql.Append(" ) " );

            List<Vw工作日志视图Entity> list = new List<Vw工作日志视图Entity>();
            Database db = GetDatabase();
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            {
			   int seq = PageSize * (CurrentPageIndex - 1);
                while (dataReader.Read())
                {
					seq++;
                    list.Add(ReaderBind(dataReader, seq));
                }
            }
            return list;
        }
		
		
			/// <summary>
        /// 按条件查询,得到一页的对应的结果列表
        /// </summary>
        /// <param name="strWhere">条件</param>
		/// <param name="PageSize">每页大小</param>
		/// <param name="CurrentPageIndex">当前页码</param>
		/// <param name="strSort">ex:order by id desc</param>
        /// <returns></returns>
		 public override List<Vw工作日志视图Entity> GetAllByQuery(string strWhere,string strSort, int PageSize, int CurrentPageIndex)
        {
            StringBuilder strSql = new StringBuilder();
            if (strWhere.Contains("order".ToLower()))
            {
                throw new Exception("分页查询的sql条件中不能包括排序子句，请调用重载方法实现有条件的排序筛选");
            }

            strSql.Append("select top ").Append(PageSize).Append("  [ID],[姓名],[RealName],[RoleGroup],[DepartmentName],[部门],[职位],[日期],[客户名称],[重要级别],[工作性质],[接报时间],[到场时间],[消耗时间],[工作内容],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy] from [Vw_工作日志视图] where ");

			 if (strWhere.Trim() != "")
            {
                strSql.Append("  " + strWhere + " and ");
            }
			  strSql.Append(" ID not in ( ");
			 strSql.Append(" select top ").Append(PageSize*(CurrentPageIndex-1)).Append("  [ID] from [Vw_工作日志视图] ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere+" " ).Append(strSort);
            }
			strSql.Append(" ) " ).Append(strSort);

            List<Vw工作日志视图Entity> list = new List<Vw工作日志视图Entity>();
            Database db = GetDatabase();
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            {
				int seq = PageSize * (CurrentPageIndex - 1);
                while (dataReader.Read())
                {	
					seq++;
                    list.Add(ReaderBind(dataReader, seq));
                }
            }
            return list;
        }
		
		
		/// <summary>
        /// 按条件查询,得到对应的结果列表
        /// </summary>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public override List<Vw工作日志视图Entity> GetAllByQuery(string strWhere)
        {
			strWhere = SQLInjectionFilter(strWhere);
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select [ID],[姓名],[RealName],[RoleGroup],[DepartmentName],[部门],[职位],[日期],[客户名称],[重要级别],[工作性质],[接报时间],[到场时间],[消耗时间],[工作内容],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy] from Vw_工作日志视图 ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            List<Vw工作日志视图Entity> list = new List<Vw工作日志视图Entity>();
            Database db = GetDatabase();
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            { 
				int seq = 0;
                while (dataReader.Read())
                {
					seq++;
                    list.Add(ReaderBind(dataReader,seq));
                }
            }
            return list;
        }
		
		
		
		/// <summary>
        /// 按条件查询,得到对应的结果列表
        /// </summary>
        /// <param name="strWhere"></param>
		/// <param name="parameters">sql条件中的参数</param>
        /// <returns></returns>
        public override List<Vw工作日志视图Entity> GetAllByQuery(string strWhere, List<IDataParameter> parameters)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select [ID],[姓名],[RealName],[RoleGroup],[DepartmentName],[部门],[职位],[日期],[客户名称],[重要级别],[工作性质],[接报时间],[到场时间],[消耗时间],[工作内容],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy] from [Vw_工作日志视图] ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            List<Vw工作日志视图Entity> list = new List<Vw工作日志视图Entity>();
            Database db = GetDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            foreach (IDataParameter sp in parameters)
            {
                db.AddInParameter(dbCommand, sp.ParameterName, sp.DbType, sp.Value);
            }

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
				int seq =0 ;
                while (dataReader.Read())
                {
					seq++;
                    list.Add(ReaderBind(dataReader,seq));
                }
            }
            return list;
        }
		
		
		

		
		
		/// <summary>
        /// 获取按条件查询以后的结果列表的前指定rowNumber行记录
        /// </summary>
        /// <param name="strWhere">不带where关键字的SQL条件语句</param>
        /// <param name="rowNumber"></param>
        /// <returns></returns>
        public override List<Vw工作日志视图Entity> GetAllByQuery(string strWhere, List<IDataParameter> parameters, int rowNumber)
        {

            StringBuilder strSql = new StringBuilder();
            strSql.Append("select top ").Append(rowNumber).Append("  [ID],[姓名],[RealName],[RoleGroup],[DepartmentName],[部门],[职位],[日期],[客户名称],[重要级别],[工作性质],[接报时间],[到场时间],[消耗时间],[工作内容],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy] from [Vw_工作日志视图] ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            List<Vw工作日志视图Entity> list = new List<Vw工作日志视图Entity>();
            Database db = GetDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            foreach (IDataParameter sp in parameters)
            {
                db.AddInParameter(dbCommand, sp.ParameterName, sp.DbType, sp.Value);
            }

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {	
				int seq = 0;
                while (dataReader.Read())
                {
					seq++;
                    list.Add(ReaderBind(dataReader,seq));
                }
            }
            return list;
        }
		
		
		/// <summary>
        /// 获取按条件查询以后的结果列表的前指定rowNumber行记录
        /// </summary>
        /// <param name="strWhere">不带where关键字的SQL条件语句: AND AA=@AA</param>
        /// <param name="rowNumber"></param>
        /// <returns></returns>
        public override List<Vw工作日志视图Entity> GetAllByQuery(string strWhere, int rowNumber)
        {
		    strWhere = SQLInjectionFilter(strWhere);
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select top ").Append(rowNumber).Append("  [ID],[姓名],[RealName],[RoleGroup],[DepartmentName],[部门],[职位],[日期],[客户名称],[重要级别],[工作性质],[接报时间],[到场时间],[消耗时间],[工作内容],[CreateDate],[CreateBy],[ModifyDate],[ModifyBy] from [Vw_工作日志视图] ");

            if (strWhere.Trim() != "")
            {
                strSql.Append(" where  " + strWhere);
            }
            List<Vw工作日志视图Entity> list = new List<Vw工作日志视图Entity>();
            Database db = GetDatabase();
            using (IDataReader dataReader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
            {
				int seq=0;
                while (dataReader.Read())
                {	
					seq++;
                    list.Add(ReaderBind(dataReader,seq));
                }
            }
            return list;
        }
		
		
		
		
		
			
		
		/// <summary>
        /// 对象实体绑定数据
		///生成构造为list的构造器
        /// </summary>
        private Vw工作日志视图Entity ReaderBind(IDataReader dataReader,int seq)
        {
            ITOMMS.Entity.Vw工作日志视图Entity entity = new ITOMMS.Entity.Vw工作日志视图Entity();
			entity.SEQNO = seq;
            object obj;
						 obj=dataReader["ID"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.ID= (int)obj;
			}
			 obj=dataReader["姓名"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.姓名= (int)obj;
			}

            obj = dataReader["RoleGroup"];
            if (obj != null && obj != DBNull.Value)
            {
                entity.RoleGroup = (int)obj;
            }
			 entity.RealName= dataReader["RealName"].ToString();
			 entity.DepartmentName= dataReader["DepartmentName"].ToString();
			 obj=dataReader["部门"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.部门= (int)obj;
			}
			 entity.职位= dataReader["职位"].ToString();
			 obj=dataReader["日期"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.日期= (DateTime)obj;
			}
			 entity.客户名称= dataReader["客户名称"].ToString();
			 entity.重要级别= dataReader["重要级别"].ToString();
			 entity.工作性质= dataReader["工作性质"].ToString();
			 obj=dataReader["接报时间"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.接报时间= (DateTime)obj;
			}
			 obj=dataReader["到场时间"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.到场时间= (DateTime)obj;
			}
			 entity.消耗时间= dataReader["消耗时间"].ToString();
			 entity.工作内容= dataReader["工作内容"].ToString();
			 obj=dataReader["CreateDate"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.CreateDate= (DateTime)obj;
			}
			 obj=dataReader["CreateBy"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.CreateBy= (int)obj;
			}
			 obj=dataReader["ModifyDate"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.ModifyDate= (DateTime)obj;
			}
			 obj=dataReader["ModifyBy"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.ModifyBy= (int)obj;
			}

            return entity;
        }
		
		
				/// <summary>
        /// 对象实体绑定数据
		///生成构造为list的构造器
        /// </summary>
        private Vw工作日志视图Entity ReaderBind(IDataReader dataReader)
        {
            ITOMMS.Entity.Vw工作日志视图Entity entity = new ITOMMS.Entity.Vw工作日志视图Entity();
			object obj;
						 obj=dataReader["ID"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.ID= (int)obj;
			}
			 obj=dataReader["姓名"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.姓名= (int)obj;
			}
			 entity.RealName= dataReader["RealName"].ToString();

             obj = dataReader["RoleGroup"];
             if (obj != null && obj != DBNull.Value)
             {
                 entity.RoleGroup = (int)obj;
             }

			 entity.DepartmentName= dataReader["DepartmentName"].ToString();
			 obj=dataReader["部门"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.部门= (int)obj;
			}
			 entity.职位= dataReader["职位"].ToString();
			 obj=dataReader["日期"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.日期= (DateTime)obj;
			}
			 entity.客户名称= dataReader["客户名称"].ToString();
			 entity.重要级别= dataReader["重要级别"].ToString();
			 entity.工作性质= dataReader["工作性质"].ToString();
			 obj=dataReader["接报时间"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.接报时间= (DateTime)obj;
			}
			 obj=dataReader["到场时间"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.到场时间= (DateTime)obj;
			}
			 entity.消耗时间= dataReader["消耗时间"].ToString();
			 entity.工作内容= dataReader["工作内容"].ToString();
			 obj=dataReader["CreateDate"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.CreateDate= (DateTime)obj;
			}
			 obj=dataReader["CreateBy"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.CreateBy= (int)obj;
			}
			 obj=dataReader["ModifyDate"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.ModifyDate= (DateTime)obj;
			}
			 obj=dataReader["ModifyBy"];
			if(obj != null && obj != DBNull.Value)
			{
			 entity.ModifyBy= (int)obj;
			}

            return entity;
        }
		
		
		
		 #endregion
		
	}
}
